import {defineStore} from 'pinia'
import { LoginInfo } from '@/models/home/login'
export const useLoginStore = defineStore('login', {
    state: () => {
        return {
            username: '用户名',
            loginTitle: '登录',
            isRegister: false,
            userInfo: {},
            remember: false
        }
    },
    getters: {
        getIsRegister(): boolean {
            return this.isRegister;
        }
    },
    actions: {
        setIsRegister(data: boolean) {
            this.isRegister = !data
        },
        setUserInfo(data: LoginInfo | any) {
            this.userInfo = data;
        },
        setRemember(data: boolean) {
            this.remember = data
        }
    },
    persist: {
        key:'login',
        storage: sessionStorage,
        paths: ['userInfo', 'remember']
    }
})